API - Cache\MySQL_cache
system\cache.php at line 604

Class MySQL_cache

Dynamic_cache_driver
└─Writeback_cache_driver
└─Db_cache_driver
└─MySQL_cache

public class MySQL_cache
extends Db_cache_driver

A very popular caching solution using MySQL as a storage. It is quite slow compared to File_cache but may be considered more reliable.

Field Summary
private array

$buffer

Prefetched data to avoid duplicate queries

Constructor Summary
void

__construct()

Performs pre-load actions

Method Summary
void

flush()

Saves all modified data with one query

void

clear(str realm)

void

exists(mixed id, mixed realm)

private int

gc()

Garbage collector function.

void

get(mixed id, mixed realm)

int

get_all(mixed realms, mixed realm)

bool

remove_now(string id, string realm)

bool

store(string id, mixed data, string realm, int ttl)

Stores data as object image in cache

bool

store_now(string id, mixed data, string realm, int ttl)

Writes item to cache immediately, avoiding writeback.

Methods inherited from API - Cache\Db_cache_driver
get_all
Methods inherited from API - Cache\Writeback_cache_driver
flush, remove, remove_now, store, store_now
Methods inherited from API - Cache\Dynamic_cache_driver
store

Field Detail

system\cache.php at line 610

buffer

private array $buffer = array()
Prefetched data to avoid duplicate queries

Constructor Detail

system\cache.php at line 615

__construct

public void __construct()
Performs pre-load actions

Method Detail

system\cache.php at line 635

flush

public void flush()
Saves all modified data with one query

system\cache.php at line 676

clear

public void clear(str realm)
See Also:
Cache_driver::clear()

system\cache.php at line 694

exists

public void exists(mixed id, mixed realm)
See Also:
Cache_driver::exists()

system\cache.php at line 714

gc

private int gc()
Garbage collector function. Removes cache entries which are not valid anymore.
Returns:
Number of entries removed

system\cache.php at line 724

get

public void get(mixed id, mixed realm)
See Also:
Cache_driver::get()

system\cache.php at line 739

get_all

public int get_all(mixed realms, mixed realm)
See Also:
Db_cache_driver::get_all()
Parameters:
realm - Realm name or array of realm names
Returns:
Number of items loaded

system\cache.php at line 773

remove_now

public bool remove_now(string id, string realm)
See Also:
Writeback_cache_driver::remove_now()
Parameters:
id - Item identifier
realm - Cache realm
Returns:

system\cache.php at line 790

store

public bool store(string id, mixed data, string realm, int ttl)
Stores data as object image in cache
Parameters:
id - Object identifier
data - Object value
realm - Realm name
ttl - Time to live, 0 for unlimited
Returns:
See Also:
Cache_driver::store()

system\cache.php at line 813

store_now

public bool store_now(string id, mixed data, string realm, int ttl)
Writes item to cache immediately, avoiding writeback.
Parameters:
id - Object identifier
data - Object value
realm - Realm name
ttl - Time to live, 0 for unlimited
Returns:
See Also:
Cache_driver::store()